package work.timejay.shop.utils;


import cn.hutool.json.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import work.timejay.shop.service.UserItemService;
import work.timejay.shop.vo.UserSend;

/**
 * @className:RocketMQConsumerUtils.java
 * @author:王文杰
 * @version:1.0.0
 * @description:rocketMQ消费消息
 * @createTime 2022年01月02日 16:02:00
 */
//@Component
//@RocketMQMessageListener(topic = "TransactionTopic",consumerGroup = "spring_boot_consumer_group")
//@Slf4j
//public class RocketMQConsumerUtils implements RocketMQListener<String> {
//    @Autowired
//    private UserItemService userItemService;
//    @Override
//    public void onMessage(String msg) {
//        log.info("msg---->{}",msg);
//        JSONObject jsonObject = JSONObject.parseObject(msg);
//        log.info("jsonObject---->{}",jsonObject);
//        Object message = jsonObject.get("message");
//        UserSend userSend = JSONObject.parseObject(message.toString(), UserSend.class);
//        //商品加1
//        userItemService.itemRecordAdd(userSend);
//        log.info("【消息接受成功】 message:{}",message);
//    }
//}
